package cn.zqy.demo3.day01.Jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class Demo01Jdbc {
    public static void main(String[] args) throws  Exception{

        //1. 导入驱动jar包
        //2.注册驱动
        Class.forName("com.mysql.jdbc.Driver");
        //3.获取数据库连接对象
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/heimadb1",
                "root", "123456");
        //4.定义sql语句
        String sql = "update a set count = 4000 where id = 1";
        //5.获取执行sql的对象 Statement
        Statement st = con.createStatement();

        //6.执行sql
        int n = st.executeUpdate(sql);

        //7.处理结果
        System.out.println(n);


        //8.释放资源
        st.close();
        con.close();
    }
}
